// Simple example of list from STL

#include <iostream>
#include <list>
using namespace std;

// Simple example uses type int

void PrintItem(int item)
{
  cout << item << " ";
}
main()
{
  list<int> L;
  L.push_back(0);              // Insert a new element at the end
  L.push_front(9);             // Insert a new element at the beginning
  // (Place before second argument)
  L.push_back(5);
  L.push_back(6);

  list<int>::iterator i;

  for(i=L.begin(); i != L.end(); ++i) cout << *i << " ";
  cout << endl;

  L.sort();
  for_each(L.begin(), L.end(), PrintItem);

  cout << endl;
  return 0;
}
